package net.display;

import javax.servlet.http.HttpServletRequest;

import net.bo.KDemande;
import net.bo.KUtilisateur;
import net.ko.displays.KObjectDisplay;
import net.ko.framework.KoSession;
import net.ko.kobject.KObject;

public class DisplayDemandePourPlan extends KObjectDisplay {

	@Override
	public String showInList(KObject ko, String memberName, HttpServletRequest request) {
		String res = super.showInList(ko, memberName, request);
		KDemande demande = (KDemande) ko;

		if ("idUtilisateur".equals(memberName)) {
			KUtilisateur user = KoSession.kloadOne(KUtilisateur.class, "id=" + demande.getIdUtilisateur());
			res = user.getLogin();
		}

		if ("btAccept".equals(memberName)) {
			res = "<input type='button' class='btn accept' id='acceptDemande-" + demande.getId() + "' value='Accepter'>";
		}

		if ("btRefus".equals(memberName)) {
			res = "<input type='button' class='btn refuse' id='refusDemande-" + demande.getId() + "' value='Refuser'>";
		}

		return res;
	}

	@Override
	public String getCaption(KObject ko, String memberName) {

		String res = super.getCaption(ko, memberName);

		if ("btAccept".equals(memberName)) {
			res = "";
		}

		if ("btRefus".equals(memberName)) {
			res = "";
		}

		return res;
	}
}